//
//  BaseViewController.swift
//  SidebarMenu
//
//  Created by LiangXiaobin on 2017/1/23.
//  Copyright © 2017年 AppCoda. All rights reserved.
//

import UIKit

class BaseViewController: UIViewController,UIGestureRecognizerDelegate,UINavigationControllerDelegate {

    var topBackView:UIView?
    var backBtn:UIButton?
    var addBtn:UIButton?
    var rightBtn:UIButton?
    var topTittle:UILabel?
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        self.navigationController?.interactivePopGestureRecognizer?.delegate = self;
        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true;
        
        
        
        
        self.view.backgroundColor = UIColor.white
        topBackView = UIView(frame: CGRect(x:0,y:0,width: screenWidth, height: 64))
        topBackView?.backgroundColor = baseColor
        self.view.addSubview(topBackView!)
        
    
        
        
        backBtn = UIButton(type:.system)
        backBtn?.frame = CGRect(x:10,y:31,width: 24, height: 43 / 2)
        backBtn?.setBackgroundImage(imaged(name: "btn_back_normal"), for: .normal)
        backBtn?.addTarget(self, action: #selector(BaseViewController.backToLastPage), for:.touchUpInside)
        self.view.addSubview(backBtn!)
        backBtn?.setEnlargeEdgeWithTop(10, right: 20, bottom: 10, left: 10)
        
        
     
        
        topTittle = UILabel(frame:CGRect(x:80,y:20,width:screenWidth - 160,height:44))
        topTittle?.font = UIFont.systemFont(ofSize: 18)
        topTittle?.textAlignment = NSTextAlignment.center
        topTittle?.textColor = UIColor.white
        self.view.addSubview(topTittle!)
        
        
        addBtn = UIButton(type: .system)
        addBtn?.frame = CGRect(x:screenWidth - 10 - 22,y:20 + 11,width:22,height:22)
        addBtn?.addTarget(self, action:#selector(BaseViewController.rightBtnClicked(sender:)) , for: .touchUpInside)
        addBtn?.setBackgroundImage(imaged(name: "btn_add_normal.png"), for: .normal)
        addBtn?.isHidden = true
        self.view.addSubview(addBtn!)
        addBtn?.setEnlargeEdgeWithTop(10, right: 20, bottom: 10, left: 10)
        
        
        rightBtn = UIButton(type: .system)
        rightBtn?.frame = CGRect(x:screenWidth - 70,y:20 + 11,width:60,height:22)
        rightBtn?.addTarget(self, action:#selector(BaseViewController.rightBtnClicked(sender:)) , for: .touchUpInside)
        rightBtn?.isHidden = true
        self.view.addSubview(rightBtn!)
        rightBtn?.setEnlargeEdgeWithTop(10, right: 10, bottom: 10, left: 0)
        

        
    
    }
    

    
//    override func preferredStatusBarStyle -> UIStatusBarStyle {
//        
//        return .lightContent
//    }
    
    


    
    
    func rightBtnClicked(sender:UIButton)
    {
        
    }
    
    func backToLastPage()
    {
//        self.navigationController?.popViewController(animated: true)
    }
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
